<?php

if($actPost=="updatephotos")
{
    $listurl		= gpc_getStringArray("ListUrl");
    $listname		= gpc_getStringArray("ListName");
    $listid			= gpc_getStringArray("ListId");
    $listorder		= gpc_getStringArray("listorder");

    foreach($listid as $i=> $id)
    {
        $id=intval($id);
        if($listurl[$i]==-1 && $id>0)
        {
            //echo $id;exit;
            $sql_delete="delete from tblbackground where iId=$id";
            $dbsql->query($sql_delete);
        }
        elseif($id<=0)
        {
        	$sql_insert = "INSERT INTO tblbackground
        					(cName,cImage,iOrder,cType,cLanguage)
        				VALUE('$listname[$i]','$listurl[$i]',1,'$module','$language')";

        	$dbsql->query($sql_insert);
        }
        else
        {
            $sql_update = "UPDATE tblbackground SET
                			 cName = '$listname[$i]',
                             iOrder= '$listorder[$i]'
                			 WHERE iId = '$id'";
            $dbsql->query($sql_update);
        }
    }
    page_transfer("Photos of Background Home page Saved");
}else
{
    $ListContent=array();

	$sql_select = "SELECT * FROM tblbackground where cType='$module'  order by iOrder";

	$rs=$dbsql->query($sql_select);
	$rows = $dbsql->num_rows($rs);
	while ( $result = $dbsql->fetch_array($rs) )
	{
		$file=basename($result['cImage']);
		$result['cThumb']=str_replace($file,"thumbs/".$file,$result["cImage"]);
		$ListContent[] = $result;
	}
}
?>